#include<stdio.h>
#include<string.h>
#include<errno.h>
#include<stdlib.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

char* const addenv[]={
    (char* const)"MYVAL1=666666666666",
    (char* const)"MYVAL2=777777777777",
    (char* const)"MYVAL3=888888888888",
    (char* const)"MYVAL4=999999999999",
    NULL
};

int main()
{
    if(fork()==0)
    {

        printf("我是子进程,My pid:%d\n",getpid());
        //char* const argv[]={(char* const)"ls",(char* const)"-l",(char* const)"-a",NULL};
        char* const argv[]={
            (char* const)"other",
            (char* const)"-a",
            (char* const)"-b",
            (char* const)"-c",
            (char* const)"-d",
            NULL
        };
        char* const env[]={
            (char* const)"MYENV=123456",
            NULL
        };
        for(int i=0;addenv[i];i++)
        {
            putenv(addenv[i]);
        }
        execvp("./other",argv);
        //extern char** environ;
        //execvpe("./other",argv,environ);
        //execv("/usr/bin/ls",argv);
        //execlp("ls","ls","-l","-a",NULL);
        //execl("./other","./other",NULL);
    }
    waitpid(-1,NULL,0);
    printf("啊嘿嘿我又来了诶\n");
    return 0;
}
